﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Itasa.RSS;


namespace Itasa
{


    /// <summary>
    /// Logica di interazione per Torrent_Item_Control.xaml
    /// </summary>
    public partial class Torrent_Item_Control : TabItem
    {

        private List<RSS_Torrent> torrentList;

        public Torrent_Item_Control(List<RSS_Torrent> lrt)
        {
            InitializeComponent();
            this.torrentList = lrt;
            if (torrentList != null)
            {
                Grid g = griglia;
                int c = 0;
                foreach (RSS_Torrent i in torrentList)
                {
                    RowDefinition rd = new RowDefinition();
                    rd.Height = GridLength.Auto;
                    g.RowDefinitions.Add(rd);
                    RSS_Torrent_Label l = new RSS_Torrent_Label(i);
                    Grid.SetColumn(l, 0);
                    l.label.Content = i.Name;
                    l.label.ToolTip = i.Name;
                    Control_Torrent_Download cd = new Control_Torrent_Download(i);
                    Grid.SetColumn(cd, 1);
                    Grid.SetRow(l, c);
                    Grid.SetRow(cd, c);
                    c++;
                    g.Children.Add(l);
                    g.Children.Add(cd);
                    if (c % 2 == 0) cd.Background = l.label.Background = new SolidColorBrush(Colors.White);
                    else cd.Background = l.label.Background = new SolidColorBrush(Colors.WhiteSmoke);
                }
            }
        }
    }
}
